const requireDirectory = require('require-directory')
class InitManage {
  static initCore(router){
    this.initLoadRouters(router)
    this.loadHttpException()
  }
  static initLoadRouters(router) {
    const apiDirectory = `${process.cwd()}/app/api`
    const modules = requireDirectory(module, apiDirectory)
    for (let r in modules) {
      for(let m in modules[r]){
        modules[r][m](router)
      }
    }
  }

  static loadHttpException(){
    const errors = require('./HttpException');
    global.errs = errors
  }
}

module.exports = InitManage
